package com.mano.mall.service.gatewayhandler.impl;

import com.mano.mall.api.dto.gatewayhandler.output.BlackListOutputDTO;
import com.mano.mall.api.gatewayhandler.BlackListService;
import com.mano.mall.common.base.BaseApiService;
import com.mano.mall.common.base.BaseResponse;
import com.mano.mall.service.mapper.BlacklistMapper;
import com.mano.mall.service.mapper.entity.Blacklist;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.sun.deploy.util.BlackList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: zj
 * @Description:
 * @Date: Created in 9:45 2020/11/13
 * @Modified By:
 */
@RestController
public class BlackListServiceImpl extends BaseApiService<BlackListOutputDTO> implements BlackListService {

    @Autowired
    private BlacklistMapper blacklistMapper;

    @Override
    @HystrixCommand(fallbackMethod = "findBlacklistCallBack")
    public BaseResponse<BlackListOutputDTO> findBlacklist(String ipAddr) {

        Blacklist blacklist = blacklistMapper.findBlacklist(ipAddr);
        return setResultSuccessDTO(blacklist);
    }

    public BaseResponse<BlackListOutputDTO> findBlacklistCallBack(String ipAddr) {
        return setResultError("服务器忙，请售后重置");
    }

}

